﻿using System.Windows.Input;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UITesting.WpfControls;

namespace CodedUITestExtensions
{
    /// <summary>
    /// Extensions for WpfEdit.
    /// </summary>
    public static class WpfEditExtensions
    {
        /// <summary>
        /// Enters text in WPFEdit using keyboard and mouse.
        /// </summary>
        /// <param name="edit">WpfEdit.</param>
        /// <param name="text">Entering text.</param>
        public static void EnterTextUsingKeyboard(this WpfEdit edit, string text)
        {
            Mouse.Click(edit);
            Keyboard.SendKeys("A", ModifierKeys.Control);
            string value = (text.Length == 0) ? "{DELETE}" : text;
            Keyboard.SendKeys(value);
        }
    }
}
